<template>
  <div>
    <Breadcrumb>
      <BreadcrumbItem>订单管理</BreadcrumbItem>
      <BreadcrumbItem>异常设置</BreadcrumbItem>
    </Breadcrumb>
    <Form ref="formInline" :model="request" inline>
      <span>动态AI柜和静态AI柜异常订单、非友好购物订单规则说明:</span>
      <FormItem>
        <Button type="primary" @click="$router.push('/orders/add')" style="margin-left: 20px;margin-top: -10px;">添加</Button>
      </FormItem>
    </Form>
    <div>
      <Table border :columns="columns2" :data="data2"   max-height="400">
        <!--罚款-->
        <template slot-scope="{ row }" slot="fine">
          <input type="text" value="50元">
        </template>
        <template slot-scope="{ row }" slot="open">
          <Form ref="formInline" inline>
            <FormItem>
              <RadioGroup v-model="formItem.radio">
                <Radio label="one">1、先扣费，后推送商家处理</Radio>
                <Radio label="two">2、直接推送给商家处理</Radio>
              </RadioGroup>
            </FormItem>
          </Form>
        </template>
        <template slot-scope="{ row }" slot="option">
          <Button type="primary">编辑</Button>
          <Button type="error" style="margin-left: 10px;">删除</Button>
        </template>
      </Table>
      <div style="margin-top: 20px;"><p>说明：订单扣费金额=异常处罚+识别正常商品金额之和，如消费者有异议，可以申请退款，商家也可以和用户核实清楚后，主动退款；</p></div>
    </div>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        formItem: {
          radio: 'one'
        },
        request: {
          name: '',
          loading: false
        },
        columns2: [
          {
            title: '识别项目',
            key: 'difference'
          },
          {
            title: '罚款(元)',
            slot: 'fine'
          },
          {
            title: ' 开关2',
            slot: 'open'
          },
          {
            title: '说明',
            key: 'explain'
          },
          {
            title: '操作',
            slot: 'option'
          }

        ],
        data2: [
          {
            difference: '用户遮挡摄像头/遮挡商品/偷吃',
            derail: '默认开启',
            explain: '按设置的扣款'
          },
          {
            difference: '用户放入异常商品（或商品逃离摄像头后放入）',
            derail: '默认开启',
            explain: '按设置的扣款'
          },
          {
            difference: '用户放入异常商品（或商品逃离摄像头后放入）',
            derail: '默认开启',
            explain: '按设置的扣款'
          }
        ],
        params: {
          device_time: [],
          status: 1,
          user_id: "",
          order_id: "",
          activity_id: "",
          page: 1,
          limit: 10,
        },
        total: 0,
        page: {},
        height: this.$store.state.height,
        modal1: false,
        data1: [
          {
            id: 1,
            title: "机器组3",
          },
          {
            id: 2,
            title: "机器组4",
          },
        ],
        request: {
          device_number: "",
          page: 1,
        },
        tableData: [],
        role_id:null,
      };
    },
    mounted() {

      this.init();
    },
    methods: {
      init(){
        this.axios.post('shop/shop_list').then((res) => {
          if (res.code === 1) {
            console.log(res)
            this.total = res.data.count
            this.tableData = res.data.list
          }
        })
      },
      // goDel(id) {
      //   this.$router.push({ path: "/order/detail", query: { id } });
      // },
      search() {
        this.params.page = 1;
        this.init();
      },
      confirm() {
        this.modal1 = false;
        this.$Message.success("保存成功！");
        this.cancel();
      },
      cancel() {},
      add() {
        this.modal1 = true;
      },
      setStatus(id, status) {
        var text = "确定要" + (status == 1 ? "启用" : "禁用") + "此机器组么？";
        this.$Modal.confirm({
          title: text,
          onOk: () => {
            this.$Message.success("操作成功");
          },
          onCancel: () => {},
        });
      },
      timechange(val) {
        console.log(val);
      },
      handleSizeChange(val) {
        this.request.page = 1;
        this.request.limit = val;
        this.lists();
      },
      handleCurrentChange(val) {
        this.params.page = val;
        this.init();
      },
      // 测试门店列表
      lists () {
        this.loading = true
        // console.log( JSON.parse(this.astgo.getItem(this.Pn + "info")).role_id )
        // this.request.id = JSON.parse(this.astgo.getItem(this.Pn + "info")).role_id;
        this.axios.post('shop/shop_list', this.request).then(res => {
          if (res.code === 1) {
            this.loading = false
            this.tableData = res.data.list
            this.page.count = res.data.count // 总条数
            this.page.curPage = res.data.curPage // 当前页
            this.page.countPage = res.data.countPage // 总页数
            console.log('this.tableData', this.tableData)
          }
        })
      },
      changeUserMsg(item, type) {
        console.log("现在的type", type);
        this.type = type;
        if (type == 1) {
          this.title = "编辑";
          this.addformInline.title = item.title;
          this.addformInline.remarks = item.remarks;
          this.addformInline.id = item.id;
          this.addUserOrChange = true;

        } else if (type == 2) {

          if (this.addformInline.id) {
            this.addformInline.id =null;
          }

          this.title = "添加";
          this.$Modal.confirm({
            title: "确定要添加角色？",
            onOk: () => {
              this.addUserOrChange = true;
            },
            onCancel: () => {}
          });
        }
      },
    },
  };
</script>

<style>
  *{
    margin: 0;
    padding: 0;
  }
  .addBold{
    font-weight: bold;

  }

</style>
